var baseUrl = "http://www.ziselu.com/zslapi/";
var imgBaseUrl = "http://www.ziselu.com/zsl/file/";
if(!localStorage.getItem("Token") && pageName(location.href) != 'login'){
    location.href = "login.html"
}
//截取网页名
function pageName(a) {
    var b = a.split("/");
    var c = b.slice(b.length - 1, b.length).toString(String).split(".").slice(0, 1)[0];
    return c;
}

//网址参数获取
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return decodeURIComponent(r[2]);
    }
    return null;
}

// ajax封装
function get_ajax(url,sendData,rebackFun) {
    if(localStorage.getItem("Token")){
        sendData["Token"] = localStorage.getItem("Token");
    }
    $.post(baseUrl+url,sendData,function (data) {
        if(data.code != 0){
            alert(data.msg);
            return
        }else{
            var data = data.data;
            rebackFun(data);
        }
    })
}

function get_ajaxPage(url,sendData,rebackFun) {
    if(localStorage.getItem("Token")){
        sendData["Token"] = localStorage.getItem("Token");
    }
    $.post(baseUrl+url,sendData,function (data) {
        if(data.code != 0){
            alert(data.msg);
            return
        }else{
            rebackFun(data);
        }
    })
}

$("body").on("click",".mask,.add_model .title span",function () {
    $(".add_model").hide();
    $(".main").show();
})
$("body").on("click",".com_style .tab_header .top_add",function () {
    $(".add_model").show();
    $(".main").hide();
})

$("body").on("click",".com_style .top_add",function () {
    $(".add_model").show();
    $(".main").hide();
})

function get_confirm(msg,rebackFun) {
    var msg = msg;
    if(typeof(msg) == "function"){
        rebackFun = msg;
        msg = '提交成功!';
    }
    if(!msg){
        msg = '提交成功!'
    }
    layer.confirm(msg, {
            btn: ['确定', '取消']
        }, function (index) {
            layer.close(index);
            if(rebackFun){
                rebackFun();
            }

        }
    );
}

$("body").on("click",".loginOut",function () {
    localStorage.removeItem("Token");
    location.href = "login.html"
})

get_ajax("/web/auth/info",{},function (data) {
    $("#username").text(data.username);
})



















































